<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>报价单</title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/list.css">
    <script>
   //检索 
   function searchListForm() {
       var params="";

       //外发加工合同
       if($("#frameFlg").val()==5)
       {
           var params1 = $("#searchForm").serialize();
           params= {"params":params1,"frameFlg" :5
           }
       }else{
            params = $("#searchForm").serialize();
       }
		$.post("${ctx}/quotation/message/searchStyleList",params, function(result) {
			var listHtml = result["style"];
			var pageHtml = result["page"];
			$("#listHtml").html(listHtml);
			$("#paging").html(pageHtml);
			
		}, 'json');
	} 
        
	 //重置
	function clean() {
		if ($("#frameFlg").val()!=3){
			$("input.customer").val("");
		}
		$("input.input").val("");
		$("select").val("");
		searchListForm();
	}    
    function selectStyle() {
    	//获取 iframe 数量 
     	var frLength = window.parent.frames.length;
     	//父画面下标 
     	var parentIndex = frLength-2;
    	var styleId = $("#listHtml tr.trSelected").find(".styleId").val();
    	var styleNO = $("#listHtml tr.trSelected").find(".styleNO").val();
    	var styleNameCN = $("#listHtml tr.trSelected").find(".styleNameCN").val();
    	var styleCatgoryCD = $("#listHtml tr.trSelected").find(".styleCatgoryCD").val();
    	var styleCatgoryCN = $("#listHtml tr.trSelected").find(".styleCatgoryCN").val();
    	var ognizationID = $("#listHtml tr.trSelected").find(".ognizationID").val();
    	var brandId = $("#listHtml tr.trSelected").find(".brandId").val();
    	var styleCustomerName = $("#listHtml tr.trSelected").find(".styleCustomerName").val();
    	var styleFile = $("#listHtml tr.trSelected").find(".styleFile").val();
    	var styleColor = $("#listHtml tr.trSelected").find(".styleColorName").val();
    	var styleStyleGroupCd = $("#listHtml tr.trSelected").find(".styleSizeGroupCD").val();
    	var styleCustomerNo = $("#listHtml tr.trSelected").find(".styleCustomerNo").val();
    	var refStyleNo = $("#listHtml tr.trSelected").find(".refStyleNo").val();
    	var styleSeason = $("#listHtml tr.trSelected").find(".styleTempSeason").val();
    	var styleYear = $("#listHtml tr.trSelected").find(".styleYear").val();
    	var styleOgnizaitonTemp = $("#listHtml tr.trSelected").find(".styleOgnizaitonTemp").val();
    	var styleTemp = $("#listHtml tr.trSelected").find(".styleTemp").val();
    	var styleRemarks = $("#listHtml tr.trSelected").find(".styleRemarks").val();
    	var styleTempSeason = $("#listHtml tr.trSelected").find(".styleSeason").val();
    	var styleSizeGroupCn = $("#listHtml tr.trSelected").find(".styleSizeGroupCn").val();
    	var customerContractNO = $("#listHtml tr.trSelected").find(".customerContractNO").val();
    	var indentQuantity = $("#listHtml tr.trSelected").find(".indentQuantity").val();
    	var creatorName = $("#listHtml tr.trSelected").find(".creatorName").val();
    	var createDate = $("#listHtml tr.trSelected").find(".createDate").val();
    	var contractID = $("#listHtml tr.trSelected").find(".contractID").val();
		var indentID = $("#listHtml tr.trSelected").find(".indentID").val();
    	if ($("#frameFlg").val()==0) {
        		window.parent.frames[parentIndex].document.getElementById("styleID").value=styleId;
        		window.parent.frames[parentIndex].document.getElementById("styleNO").value=styleNO;
        		window.parent.frames[parentIndex].document.getElementById("styleNameCN").value=styleNameCN;
        		//window.parent.frames[parentIndex].document.getElementById("styleFile").src=styleFile;
        		window.parent.frames[parentIndex].document.getElementById("styleCustomerName").value=styleCustomerName;
        		window.parent.frames[parentIndex].unitFun(styleId,"unitCostNO");
        		window.parent.frames[parentIndex].imageList(styleId,styleFile);
    			closeWin();
    	} else if ($("#frameFlg").val()==1){
    			window.parent.frames[parentIndex].selectStyleCallBack(styleId,styleNameCN,styleFile,
    			styleColor,styleStyleGroupCd,styleCustomerNo,refStyleNo,styleSeason,styleYear,
    			styleOgnizaitonTemp,styleTemp,styleRemarks);
    			closeWin();
    	//大货单耗
    	} else if ($("#frameFlg").val()==2) {
        		window.parent.frames[parentIndex].document.getElementById("styleId").value=styleId;
        		window.parent.frames[parentIndex].document.getElementById("styleNo").value=styleCustomerNo;
        		window.parent.frames[parentIndex].document.getElementById("styleNameCn").value=styleNameCN;
        		// 排版单耗编号
        		window.parent.frames[parentIndex].unitFun(styleId,"unitCostNo");
        		window.parent.frames[parentIndex].findMaterial(styleId);
        		closeWin();
    	} else if ($("#frameFlg").val()==3) {
        		window.parent.frames[parentIndex].changeSelect(ognizationID);
        		window.parent.frames[parentIndex].strHtml(styleId,styleFile,styleCustomerNo,styleNameCN,styleCatgoryCN);
    			closeWin();
    	}else if ($("#frameFlg").val()==4) {
    		window.parent.frames[parentIndex].selectStyleCallBack(styleId,styleNO,styleNameCN,styleTempSeason,styleCatgoryCN,styleCustomerName,refStyleNo,styleYear,styleColor,styleSizeGroupCn,styleTemp,styleCustomerNo,styleFile,false,styleRemarks,styleStyleGroupCd,ognizationID,0,styleCatgoryCD);
    		closeWin();
    	}else if ($("#frameFlg").val()==5) {
			window.parent.frames[parentIndex].selectStyle(styleId,indentID,contractID,styleCustomerNo,styleNameCN,styleFile,styleCatgoryCN,styleCustomerName,customerContractNO,indentQuantity,creatorName,createDate);
			closeWin();
		}
	}
    //选择按钮事件
    function selectFunction(obj){
    	$("#listHtml tr").removeClass('trSelected');
    	$(obj).addClass('trSelected');
    	
    }
    </script>
    
</head>
<body style="min-width: 870px">
<form id="searchForm">
<input type = "hidden" id = "frameFlg" value="${quotation.frameFlg}"/>
<div class="layerHeader clearfix" style="width: 900px">
	<p class="headerTitle"><spring:message code="quotation_style_selectStyle" /></p>
	<div class="headerButton clearfix">
                <button type="button" onclick="searchListForm();"><spring:message code="quotation_style_search" /></button>
                <button type="button" onclick="clean();"><spring:message code="common_reset" /></button>
                <button type="button" onclick="selectStyle();"><spring:message code="quotation_style_selected" /></button>
                <button type="button" onclick="closeWin();"><spring:message code="quotation_style_cancle" /></button>
                </div>
</div>
<div class="listArea" style="width: 900px">
	<div class="listBg">
        <div class="searchArea clearfix">
            <div id="showHtml" class=" clearfix">
                <div class="searchInp clearfix">
                    <p><spring:message code="quotation_style_styleName" /></p>
                    <input id="styleNameCN" name="styleNameCN" class="w-customer input" value="">
                </div>
                <div class="searchInp clearfix">
                    <p><spring:message code="quotation_style_styleType" /></p>
                    <c:set value="STYLE_CATEGORY" var="catgoryList"/>
                        <select id="styleCatgoryCD" name="styleCatgoryCD" style="width: 110px">
                            <option value=""><spring:message code="quotation_style_pleaseSelect" /></option>
                        <c:forEach items="${fns:getDictList(catgoryList) }" var="styleCatgory">
                            <option  value="${styleCatgory.itemCode}-${styleCatgory.itemValue}">${styleCatgory.itemName}</option>
                        </c:forEach>
                        </select>
                </div>
                <div class="searchInp clearfix">
                    <p><spring:message code="quotation_style_year" /></p>
                    <input id="styleYear" name="styleYear" class="w-styleNub input" value="">
                </div>
                <div class="searchInp clearfix items">
                    <p><spring:message code="quotation_style_customer" /></p>
                    <input id="styleCustomerName" name="styleCustomerName" class="w-customer customer" value="${quotation.styleCustomerName }">
                </div>
            </div>
                
        </div>
   
        <div class="tableArea tabBoxSm" >
            <div class="tableScroll tabSm" style="overflow: auto;height: 420px;width:860px">
                <table cellpadding="0" class="tableHead " >
                    <thead>
                    <tr>
                        <th><p class="tab-No"><spring:message code="common_no" /></p></th>
                        <th><p class="tab-kstp"><spring:message code="quotation_style_styleImage" /></p></th>
                        <th><p class="tab-khksmc"><spring:message code="quotation_style_styleNoName" /></p></th>
                        <th><p class="tab-kslb"><spring:message code="quotation_style_styleType" /></p></th>
                        <th><p class="tab-jjnf"><spring:message code="quotation_style_yearSeason" /></p></th>
                        <%-- <th><p class="tab-ml"><spring:message code="quotation_style_material" /></p></th> --%>
                        <th><p class="tab-ksys"><spring:message code="quotation_style_StyleColor" /></p></th>
                        <th><p class="tab-kh"><spring:message code="quotation_style_styleCustomer" /></p></th>
                        <th><p class="tab-cjr"><spring:message code="quotation_style_creator" /></p></th>
                        <th><p class="tab-cjrq"><spring:message code="quotation_style_createDate" /></p></th>
                    </tr>
                    </thead>
                </table>
                <table cellpadding="0" class="tableBody" >              
                    <tbody id = "listHtml">
                    
                    </tbody>
                </table>
            </div>
            
        </div>
    </div>
    <div id = "paging" ></div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
	$("#styleCatgoryCD").select2();
	if ($("#frameFlg").val()==3||$("#frameFlg").val()==5){
		if ($("#styleCustomerName").val()!=null&&$("#styleCustomerName").val()!="") {
			$("#showHtml").addClass("showHtml");
			$('.items').find('input').attr('readOnly','readOnly');
		}
	}
	searchListForm();
});
</script> 
</body>
</html>
	